package com.bwie.message.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.Query;

import com.bwie.message.dao.MessageDao;
import com.bwie.message.entity.MessageEntity;
import com.bwie.message.service.MessageService;


@Service("messageService")
public class MessageServiceImpl extends ServiceImpl<MessageDao, MessageEntity> implements MessageService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<MessageEntity> wrapper = new QueryWrapper<>();
        String type = (String) params.get("type");

        if (StringUtils.isNotEmpty(type)){
            wrapper.eq("message_type",type);
        }

        IPage<MessageEntity> page = this.page(
                new Query<MessageEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }
}